﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.Collections.Generic;

    public sealed class SerializationContext
    {
        private Dictionary<long, ObjectPath> m_paths = new Dictionary<long, ObjectPath>();

        internal SerializationContext()
        {
        }

        public void AddClientObject(ClientObject obj)
        {
            if (obj.Path != null)
            {
                this.AddObjectPath(obj.Path);
            }
        }

        public void AddObjectPath(ObjectPath path)
        {
            this.m_paths[path.Id] = path;
        }

        internal void AddObjectPathsFrom(SerializationContext context)
        {
            foreach (KeyValuePair<long, ObjectPath> pair in context.Paths)
            {
                this.AddObjectPath(pair.Value);
            }
        }

        internal Dictionary<long, ObjectPath> Paths
        {
            get
            {
                return this.m_paths;
            }
        }
    }
}

